package cn.ming.wfchat.app.login;

import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

import androidx.core.app.ActivityOptionsCompat;
import butterknife.BindView;
import butterknife.OnClick;

import cn.ming.wfchat.R;
import cn.ming.wfchat.app.AppService;
import cn.ming.wfchat.app.login.model.LoginPhoneResult;
import cn.ming.wfchat.kit.WfcBaseActivity;
import cn.wildfirechat.remote.ChatManager;


/**
 * use {@link SMSLoginActivity} instead
 */
public class LoginPhoneActivity extends WfcBaseActivity {
    @BindView(R.id.loginButton)
    TextView loginButton;
    @BindView(R.id.phoneNumberEditText)
    EditText phoneNumberEditText;


    @Override
    protected int contentLayout() {
        return R.layout.login_activity_phone;
    }

    @Override
    protected void afterViews() {
    }

    @OnClick(R.id.loginButton)
    void next() {
        AppService.Instance().validateImei(phoneNumberEditText.getText().toString().trim(), new AppService.OphoneCallback() {
            @Override
            public void onUiSuccess(LoginPhoneResult result) {
                Intent intent;
                intent = new Intent(LoginPhoneActivity.this, SMSLoginActivity.class);
                intent.putExtra("account",phoneNumberEditText.getText().toString().trim());
                intent.putExtra("whetherImei",result.isWhetherImei());
                intent.putExtra("whetherPassword",result.isWhetherPassword());
                startActivity(intent);
                finish();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                ChatManager.showToast("请求失败" + msg);
            }
        });

    }
}
